feat(algorithms graphs): course schedule#101
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughAdds Course Schedule content and tests: a Kahn’s-algorithm Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as User/Test
participant can_finish as can_finish()
participant Graph as AdjacencyList
participant Queue as ZeroInDegreeQueue
Caller->>can_finish: call(num_courses, prerequisites)
can_finish->>Graph: build adjacency list & compute in-degrees
can_finish->>Queue: enqueue nodes with in-degree == 0
rect rgb(235, 248, 235)
loop process queue
Queue->>can_finish: pop node u
can_finish->>Graph: for neighbor in Graph[u]
can_finish->>Graph: decrement in-degree[neighbor]
alt in-degree[neighbor] == 0
can_finish->>Queue: enqueue neighbor
end
end
end
alt processed_count == num_courses
can_finish->>Caller: return True
else
can_finish->>Caller: return False
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (80)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (9)
algorithms/graphs/course_schedule/images/solution_2_slide_1.pngis excluded by!**/*.pngalgorithms/graphs/course_schedule/images/solution_2_slide_2.pngis excluded by!**/*.pngalgorithms/graphs/course_schedule/images/solution_2_slide_3.pngis excluded by!**/*.pngalgorithms/graphs/course_schedule/images/solution_2_slide_4.pngis excluded by!**/*.pngalgorithms/graphs/course_schedule/images/solution_2_slide_5.pngis excluded by!**/*.pngalgorithms/graphs/course_schedule/images/solution_2_slide_6.pngis excluded by!**/*.pngalgorithms/graphs/course_schedule/images/solution_2_slide_7.pngis excluded by!**/*.pngalgorithms/graphs/course_schedule/images/solution_2_slide_8.pngis excluded by!**/*.pngalgorithms/graphs/course_schedule/images/solution_2_slide_9.pngis excluded by!**/*.png
📒 Files selected for processing (4)
DIRECTORY.md(1 hunks)algorithms/graphs/course_schedule/README.md(3 hunks)algorithms/graphs/course_schedule/__init__.py(1 hunks)algorithms/graphs/course_schedule/test_course_schedule.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
algorithms/graphs/course_schedule/__init__.py (1)
datastructures/graphs/__init__.py (2)
topological_sorted_order(61-112)dfs(84-105)
algorithms/graphs/course_schedule/test_course_schedule.py (1)
algorithms/graphs/course_schedule/__init__.py (2)
find_order(9-73)can_finish(76-127)
🪛 LanguageTool
algorithms/graphs/course_schedule/README.md
[grammar] ~62-~62: Use a hyphen to join words.
Context: ...-- ## Solution 1 Breakdown (Using Depth First Search) Suppose we are at a node ...
(QB_NEW_EN_HYPHEN)
[style] ~147-~147: Consider removing “of” to be more concise
Context: ...ty will be O(V+E) because we’re storing all of the edges for each vertex in an adjacency l...
(ALL_OF_THE)
🪛 markdownlint-cli2 (0.18.1)
DIRECTORY.md
78-78: Unordered list indentation
Expected: 0; Actual: 2
(MD007, ul-indent)
79-79: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
80-80: Unordered list indentation
Expected: 4; Actual: 6
(MD007, ul-indent)
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/pre-commit.yml (1)
9-10: Verify action version upgrades for compatibility.The checkout and cache actions have been upgraded to newer major versions (v2→v5 and v2→v4 respectively). Ensure these upgrades don't introduce breaking changes with the current cache configuration on lines 12-15.
Additionally, consider upgrading
actions/setup-python@v2on line 16 to a newer version for consistency, as it's now the only outdated action in this workflow (currently at v2 while others are at v4-v5).
Describe your change:
Adds an additional alternative solution with tests to the course schedule algorithm problem
Checklist:
Fixes: #{$ISSUE_NO}.Summary by CodeRabbit